/***********************************************************
 *
 * Gaoth
 * Copyright (c) 2011- Marcus Lundgren
 *
 * This software is provided 'as-is', without any express or implied warranty.
 * In no event will the authors be held liable for any damages arising from
 * the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it freely,
 * subject to the following restrictions:
 *
 *  1. The origin of this software must not be misrepresented; you must not
 *     claim that you wrote the original software. If you use this software
 *     in a product, an acknowledgment in the product documentation would be
 *     appreciated but is not required.
 *
 *  2. Altered source versions must be plainly marked as such,
 *     and must not be misrepresented as being the original software.
 *
 *  3. This notice may not be removed or altered from any source distribution.
 *
 ***********************************************************/

#pragma once

#include <irrlicht/irrlicht.h>
#include "../../model/model.h"

/**
 * Enum for the states, which is used to determine
 * the next state.
 */
enum States
{
    ABOUT_STATE = 0,
    GAME_STATE,
    MENU_STATE,
    END_STATE
};

/**
 * Interface that defines a state.
 */
class IState
{
public:
    /**
     *
     */
    IState( irr::IrrlichtDevice *window, irr::video::IVideoDriver *driver, irr::scene::ISceneManager *scene_man,
            irr::gui::IGUIEnvironment *gui_env, Model *model )
    : _window( window ), _driver( driver ), _scene_mgr( scene_man ), _gui_env( gui_env ), _model( model ), _is_done( false ) {}
    /**
     * Destructor.
     */
    virtual ~IState()
    {
        // We are not the owner
        _window    = 0;
        _driver    = 0;
        _scene_mgr = 0;
        _gui_env   = 0;
        _model     = 0;
    };
    /**
     * Initializes the state.
     */
    virtual void init() = 0;
    /**
     * Checks if the state is done.
     *
     * @return true if the state is done, false otherwise.
     */
    bool is_done() const
    {
        return _is_done;
    }
    /**
     * Returns the state which should follow this one.
     *
     * @return the next state.
     */
    States get_next_state() const
    {
        return _next_state;
    }
    /**
     * Updates the state by the given number of seconds.
     *
     * @param time time in seconds since the last update.
     */
    virtual void update( const float time ) = 0;
    /**
     * Draws the state.
     */
    virtual void draw() const = 0;
protected:
    irr::IrrlichtDevice *_window;
    irr::video::IVideoDriver *_driver;
    irr::scene::ISceneManager *_scene_mgr;
    irr::gui::IGUIEnvironment *_gui_env;
    Model *_model;
    States _next_state;
    bool _is_done;
private:
    // Illegal
    IState();
    IState( const IState& );
    IState& operator=( IState& );
};
